<template>
	<view class="content pc-tou-gao " >
		<view class="scroll-fix" >

		
			<view class="d-kuan-juzhong ">
				<!--头部-->
				<view class="d-kuan pc-dingbu ">
					
					
				</view>
				


				<!--头部-->
				<!--下面内容-->
				<view class="d-kuan d-clear">
					<uv-row customStyle="margin-bottom: 10px" :gutter="10">
						<uv-col span="2" class="pc-yincang">
							<!--左边导航-->
							
						</uv-col>

						<uv-col :span="kuan_shu">
							
								
								
								
							<view class="pc-neikuang-20-list" >
								<view class="denglu" >
									<view class="denglu_2" >
										<view class="d-kuan">
											<view class=" ">
												<view class="title">
													<view>Hello！<br>欢迎来到{{ wwwData && wwwData.setting && wwwData.setting.config.SITE_NAME }}</view>
												</view>
												<view class="form">
													<view class="tab">
														<view v-if="phone == 1" :class="loginType==1? 'select type1' : 'type1'" @click="loginType=1">快捷登录</view>
														<view  :class="loginType==2? 'select type2' : 'type2'" @click="loginType=2">账号登陆</view>
														<view  :class="loginType==3? 'select type2' : 'type3'" @click="loginType=3">注册</view>
													</view>
													<view class="inputs">
														<view v-if="loginType==1" class="account">
															<view>+86</view> <input type="number" v-model="yonghu.phone" :adjust-position="false"
																placeholder="手机号" />
														</view>
														<view v-if="loginType==2" class="account">
															 <input type="text" v-model="yonghu.username" :adjust-position="false"
																placeholder=" 账号" />
														</view>
								
														<view v-if="loginType==1" class="vcode">
															<input type="number" v-model="yonghu.vcode" :adjust-position="false" placeholder="请输入验证码" />
															<text v-if="vcodeTime==0" style="color:#16afa8" @click="postRenzhengma">获取验证码</text>
															<text v-else style="color:#ccc">重新获取({{vcodeTime}}s)</text>
														</view>
														<view  v-if="loginType==2" class="vcode">
															<input type="password" v-model="yonghu.password" :adjust-position="false" placeholder="请输入密码" />
														</view>
														
														<!--账号登录-->
														<view v-if="loginType==3 && username == 1" class="vcode">
															 <input type="text" v-model="yonghu.username" :adjust-position="false"
																placeholder=" 账号" />
														</view>
														<view v-if="loginType==3 && phone == 1" class="vcode">
															<view class="d-you-10">+86</view> <input type="number" v-model="yonghu.phone" :adjust-position="false"
																placeholder="手机号" />
														</view>
														<view  v-if="loginType==3 && email == 1" class="vcode">
															<input type="text" v-model="yonghu.email" :adjust-position="false" placeholder="请输入邮箱" />
														</view>
														<view  v-if="loginType==3" class="vcode">
															<input type="password" v-model="yonghu.password" :adjust-position="false" placeholder="请输入密码" />
														</view>
														<view v-if="loginType==3 && code == 1" class="vcode">
															<view class="d-you-10" >
																<!--图片认证码-->
																<image @click="getRenzhengma" :src="get_rzm" mode="aspectFill" class="erweima" style="width: 80px; height: 40px;"></image>
															</view> 
															<input type="text" v-model="yonghu.code" :adjust-position="false"
																placeholder="认证码" />
														</view>
								
													</view>
													<view v-if="loginType==1" class="button">
														<view @click="zhuce">
															立即登录
														</view>
													</view>
													<view v-if="tishi" class="tip d-xia-10" style="color: #16afa8;">
														<text>{{tishi}}</text>
													</view>
													<view v-if="loginType==2" class="button">
														<view @click="denglu_data">
															立即登录
														</view>
													</view>
													<view v-if="loginType==3" class="d-juzhong d-zitiyanse-hongse">
														<view @click="zhuce_data">
															新用户注册
														</view>
													</view>
													<view v-if="loginType==1" class="tip">
														<text>未注册的手机号验证后即可完成注册</text>
													</view>
													
													
													
													<view v-if="loginType==1" class="pact">
														<radio :checked="pactChecked" activeBackgroundColor="#3ba662" activeBorderColor="#3ba662"
															borderColor="#3ba662" color="#fff" @click="pactChange" />
														<view>我已阅读并同意<text @click="toPact">《用户协议》</text>和<text @click="toPact">《隐私协议》</text></view>
													</view>
													
													<view class="tip">
														<text @click="shouye">返回首页</text>
													</view>
												</view>
								
								
								
											</view>
											
								
								
										</view>
									</view>
								
								
								
								</view>
								  
								
								
							</view>
						</uv-col>
						<uv-col span="3" class="pc-yincang">
							<view class="d-daohang d-you-10 pc-yincang d-shang-20" id="zuo-daohang" :style="{height: leftNavHeight}">
								<view class="d-you-kuang">
									<!--view class="d-kuan  " id="yuedu_gao" :style="{height: leftNavHeight,width: rightColWidth,marginTop: '10px'}">
										<view class=" gundong-2"  style="height: 100%; display: flex; flex-direction: column;overflow-y: auto;">
											<view class="d-yuanjiao-10  d-beijing-e3 d-bianhua-10 ">
												<view class="d-kuan d-jiacu d-wenzi-16">
													站点资讯
												</view>
												<view class="d-hanggao-37 d-buhuanhang d-wenzi-16 d-quxian-0 d-chaochu d-shangxia-5">
													<view class="d-jiacu d-you-10 d-zitiyanse-hongse">1</view>
													<view data-id="20" data-toggle="modal" data-target="#myModalssss" class="tantie"> 
														Xiaomi 14 真机展示图					
													</view>
												</view>
												<view class="d-hanggao-37 d-buhuanhang d-wenzi-16 d-quxian-0 d-chaochu d-shangxia-5">
													<view class="d-jiacu d-you-10 d-zitiyanse-hongse">1</view>
													<view data-id="20" data-toggle="modal" data-target="#myModalssss" class="tantie"> 
														Xiaomi 14 真机展示图					
													</view>
												</view>

												<view class="d-hanggao-37 d-buhuanhang d-wenzi-16 d-quxian-0 d-chaochu d-shangxia-5">
													<view class="d-jiacu d-you-10 d-zitiyanse-hongse">1</view>
													<view data-id="20" data-toggle="modal" data-target="#myModalssss" class="tantie"> 
														Xiaomi 14 真机展示图					
													</view>
												</view>
												<view class="d-hanggao-37 d-buhuanhang d-wenzi-16 d-quxian-0 d-chaochu d-shangxia-5">
													<view class="d-jiacu d-you-10 d-zitiyanse-hongse">1</view>
													<view data-id="20" data-toggle="modal" data-target="#myModalssss" class="tantie"> 
														Xiaomi 14 真机展示图					
													</view>
												</view>


											</view-->
											<!--推荐圈子-->
											<!--view class="d-yuanjiao-10 d-waigao-20 d-beijing-e3 d-bianhua-10 ">
												<view class="d-kuan d-jiacu d-wenzi-16">
													推荐圈子
												</view>
												<uv-row customStyle="margin-bottom: 10px">
													<uv-col span="3" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<uv-avatar src="/static/img/011.jpg" shape="square"></uv-avatar>
														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="3" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<uv-avatar src="/static/img/011.jpg" shape="square"></uv-avatar>
														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="3" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<uv-avatar src="/static/img/011.jpg" shape="square"></uv-avatar>
														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="3" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<uv-avatar src="/static/img/011.jpg" shape="square"></uv-avatar>
														<view class="demo-layout bg-purple">321</view>
													</uv-col>


												</uv-row>


											</view-->
											<!--推荐课程-->
											<!--view class="d-yuanjiao-10 d-waigao-20 d-beijing-e3 d-bianhua-10 ">
												<view class="d-kuan d-jiacu d-wenzi-16">
													推荐课程
												</view>
												<uv-row customStyle="margin-bottom: 10px;flex-wrap: wrap">
													<uv-col span="6" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<view class="d-zuo d-tu-kuan-110 d-piaofu-0">

															<uv-image src="http://im.duixin.com/uploadfile/202507/86f3134bfebdfdf.jpg" width="190rpx" height="240rpx" radius="10"></uv-image>
														</view>

														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="6" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<view class="d-zuo d-tu-kuan-110 d-piaofu-0">

															<uv-image src="http://im.duixin.com/uploadfile/202507/86f3134bfebdfdf.jpg" width="190rpx" height="240rpx" radius="10"></uv-image>
														</view>

														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="6" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<view class="d-zuo d-tu-kuan-110 d-piaofu-0">

															<uv-image src="http://im.duixin.com/uploadfile/202507/86f3134bfebdfdf.jpg" width="190rpx" height="240rpx" radius="10"></uv-image>
														</view>

														<view class="demo-layout bg-purple">321</view>
													</uv-col>
													<uv-col span="6" customStyle="display: flex; flex-direction: column; align-items: center;margin-top: 10px">
														<view class="d-zuo d-tu-kuan-110 d-piaofu-0">

															<uv-image src="http://im.duixin.com/uploadfile/202507/86f3134bfebdfdf.jpg" width="190rpx" height="240rpx" radius="10"></uv-image>
														</view>

														<view class="demo-layout bg-purple">321</view>
													</uv-col>



												</uv-row>


											</view-->
											<!--底部-->
											<!--view class="d-kuan d-waigao-20 d-bianhua-10 "></view>																		
										</view>																								
									</view-->
								</view>
							</view>
						</uv-col>
					</uv-row>

					

				</view>
				<!--下面内容-->


			</view>

			<view class="d-clear"></view>
		
		</view>
		<!--底部-->
		<view class="d-kuan d-waigao-20 d-bianhua-10 pc-yincang"></view>

		<view class="d-clear pc-yincang"></view>
		<view class="d-weibu pc-yincang">
			<Dweibu></Dweibu>
		</view>

	</view>
</template>

<script>
    import Api from '@/utils/api.js'; 
	
	import QuanApi from '@/utils/quan_api.js';
	import UApi from '@/utils/u_api.js';
	import { getRequest,postRequest } from '@/utils/wxRequest.js';
    
	
	
	
	
	export default {
		data() {
			return {
				wwwData: null, // 存储首页数据
				vcodeTime: 0,
		        vcodeTimer: null,
				uid:'', // 用户id
				title: 'Hello',
				leftNavHeight: '500rpx', // 默认高度
                rightColWidth: '300px', // 默认宽度
				rightColLeft: '0px', // 添加这个属性
				
				
				
				tubiaolist: 
				['integral', 'kefuv-ermai', 'coupon', 'gift', 'scan',
					'pause-circle', 'volume-off', 'email', 'list'
				],
				denglu_xianshi:0, // 登录显示

				tiezi_list:[], // 帖子列表

				currentPage: 1, //下拉加载
    			pageSize: 12, //下拉加载
    			isLoading: false, //下拉加载
    			noMoreData: false, //下拉加载
				
				kuan_shu: 7, //格大小
				swiperHeight: '250',
				gao: '20', //图片高度
				daohang_list: [
					{
						name: '帖子',
						id: '1'
					}, {
						name: '圈子',
						id: '2'
					}

				],
				quan_data:[],
				
				shenhe_shu:0,//审核帖子数量
				u_data:[], // 用户信息
				dataLoaded: false,
				guanzhu_panduan:0,
				yonghu:[{
					username:'',
					phone:'',
					email:'',
					name:'',
					password:'',
					password2:'',
					vcode:''
				}],
				pactChecked: false, // 协议勾选状态
			    showDropdown: false,
				
				loginType: 1,
				xieyizhi:[], //协议值
				tishi:'', //提示
				zhucexuanxiang:[], //注册选项
				zhuce: 1, //注册类型 1手机号 2邮箱
				email: 0, //是否注册邮箱
				username: 0, //是否注册用户名
				phone: 0, //是否注册手机号
				get_rzm: '', //获取注册认证码
				code: 0, //是否需要验证码
				


			}
		},
		components: {
  		    
  		},
		mounted() {
			//var m = this.$store.state;
			//console.log('mmmm',m);
			
    	    this.setLeftNavHeight();
			this.getRightColWidth(); // 添加这行
            // 添加窗口大小变化监听
           // #ifdef H5
            window.addEventListener('resize', this.setLeftNavHeight);
            window.addEventListener('resize', this.getRightColWidth); // 添加窗口大小变化监听
           // #endif
            var e = this;
			//this.onImageLoad(e);
			// 调用方法获取全局数据
			this.loadWwwData();
    	},
    	beforeDestroy() {
    	    // 移除监听
           // #ifdef H5
            window.removeEventListener('resize', this.setLeftNavHeight);
            window.removeEventListener('resize', this.getRightColWidth); // 添加这行
           // #endif
    	},
		onShow() {
			//var m = this.$store.state;
			//this.denglu_fabu();
			this.zhucexiangmu();
			this.getRenzhengma();
		},
		onLoad(e) {
			this.uid = e.uid; // 会员id
			
			console.log('uid:', e.uid);
			
		},
		computed: {
		  yidenglu() {
		    return (this.$store.state.memberuid && this.$store.state.keycode) ? 1 : 0;
		  },
		  touxiang() {
		    return this.$store.state.member? this.$store.state.member.avatar : '';
		  },
		  name1() {
		    return this.$store.state.member? this.$store.state.member.name : '';
		  }
		},
		onReachBottom() {
  			this.onReachBottom(); //下拉加载分页
  		},

		methods: {
			// 加载www全局数据
			async loadWwwData() {
			    try {
			        // 方式1：使用全局挂载的方法
			        const data = await this.$getWwwData();
			        this.wwwData = data;
			       // console.log('通过全局挂载方法获取到的www数据:', data);
			        
			        // 方式2：直接从缓存中获取（如果只需要缓存数据而不需要最新数据）
			        // const cachedData = uni.getStorageSync('www');
			        // if (cachedData) {
			        //     this.wwwData = cachedData;
			        //     console.log('从缓存获取到的www数据:', cachedData);
			        // }
			    } catch (error) {
			        //console.error('获取www数据失败:', error);
			        // 出错时尝试从缓存获取数据
			        const cachedData = uni.getStorageSync('www');
			        if (cachedData) {
			            this.wwwData = cachedData;
			           // console.log('从缓存获取到的www数据:', cachedData);
			        }
			    }
			},
			
			getRightColWidth() {
				// 获取系统信息
				const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowWidth = systemInfo.windowWidth;
				var d = this;

                this.$nextTick(() => {
				if(windowWidth >=1221){
					d.gao = 20;
					d.kuan_shu = 7;
					d.swiperHeight = '250';
				} else {
					d.gao = 10;
					d.kuan_shu = 12;
					d.swiperHeight = '120';

				}
				console.log('窗口高度:', windowWidth);

                 const query = uni.createSelectorQuery().in(this);
                 query.select('#youbiankuan').boundingClientRect(rect => {
                   if (rect) {
                     /*this.rightColWidth = `${rect.width+20}px`;
                     console.log('右侧列宽度:', this.rightColWidth);*/
					 	this.rightColWidth = `${rect.width-80}px`;
                    	this.rightColLeft = `${rect.left}px`; // 计算左侧位置
                    	console.log('右侧列位置:', this.rightColWidth);
                   }
                 }).exec();
               });
            },

			//首页
			shouye(){
				uni.navigateTo({
					url: '/pages/index/index',
					fail: (err) => {
						console.error('跳转失败:', err)
					}
				})
			},
			
			
			
			setLeftNavHeight() {
        	    // 获取系统信息
        	    const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowHeight = systemInfo.windowHeight;
        	    const headerHeight = 70; // 头部高度估计值
        	    const calculatedHeight = windowHeight - headerHeight;
				
        	    // 设置左边导航高度
        	    this.leftNavHeight = `${calculatedHeight}px`;
        	},
			
			
			handleLoginSuccess() {
  			  this.$forceUpdate();
  			},
			
			
			
			
			denglu_fabu(){
				if(this.yidenglu == 0){
					this.denglu_xianshi = 1;
					
				} else {
					this.denglu_xianshi = 0;
						
				}
				
				console.log('发布登录',this.denglu_xianshi);
				
			},
			// 更新判断是否登录
			handleUpdateDengluxianshi(value) {
			  this.denglu_xianshi = value;
			  console.log('关闭登录',this.denglu_xianshi);
			},
			
			
			
			
			
			//个人信息
			getu_api(){
				var uid = this.$store.state.memberuid;
				var keycode = this.$store.state.keycode;
				const data = {
						uid: this.uid,

						api_auth_uid: uid,
						api_auth_code: keycode,
					}
				var get_data = getRequest(UApi.getU(),data);
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						if(this.uid){
							//this.u_data = res.data.data.wo;
						} else {
							//this.u_data = res.data.data.u;
						}
						this.u_data = res.data.data.u;
						//this.u_data = res.data.data;
						this.dataLoaded = true;
						
					}
				})

			},
			
			
			// 返回
            fanhui() {
				// 先清理音频
				
               // 获取页面栈
                 const pages = getCurrentPages();
                 // 如果页面栈长度小于等于1，说明没有上一级页面
                 if (pages.length <= 1) {
                    console.log('没有上一级页面');
                    uni.reLaunch({
                      url: '/pages/index/index'
                    });
                 } else {
                    // 有上一级页面则返回
                    uni.navigateBack({
                      delta: 1
                    });
                }
            },
			// 用户注册
			async zhuce(){
				try {
					var d = this;
					
					if(!d.xieyizhi || d.xieyizhi.length === 0) {
						
        			    uni.showToast({
        			        title: '请先同意用户协议和隐私协议',
        			        icon: 'none'
        			    });
        			    return;
        			}

					var username = d.yonghu.username; //账号
					var name = d.yonghu.name; //账号
					var password = d.yonghu.password; //密码
					var password2 = d.yonghu.password; //确认密码2
					var email = d.yonghu.email; //邮箱可选
					var phone = d.yonghu.phone; //手机号码可选
					var protocol = d.xieyizhi[0]; //是否同意协议
					var vcode = d.yonghu.vcode; //验证码
					//var datas = "is_ajax=1&data[password]="+password+"&data[password2]="+password2+"&is_protocol="+protocol;
					var datas = "&is_ajax=1";
					if(username){
						datas += '&data[username]=' + username;
					}
					if(phone){
						datas += '&data[phone]=' + phone;
					}
					if(email){
						datas += '&data[email]=' + email;
					}
					if(name){
						datas += '&data[name]=' + name;
					}
					if(vcode){
						datas += '&sms=' + vcode;
					}
					//postYonghuRegiste
					/*const params = {
    				    is_ajax: 1,
    				    is_protocol: protocol,
    				    data: {
							...(name && {username: name}),
							...(username && {username: username}), // 只有username有值时才包含在data中
							...(email && {email: email}), // 只有email有值时才包含在data中
							...(phone && {phone: phone}), // 同样处理phone
    					    password: password,
    					    password2: password2
    					},
    				    
    				    
    				};*/
					var post_data = postRequest(Api.postYonghuLogin_sms(),datas);
					var res;
					post_data.then(response => {
						res = response;
						if(res.data.code) {	
							uni.showToast({
								title: '操作成功',
								icon: 'success',
								duration: 2000
							});
							 // 保存用户信息到本地storage
							//uni.setStorageSync('userInfo', response.data.data.member.auth);
							uni.setStorageSync('memberuid', response.data.data.member && response.data.data.member.id);
							uni.setStorageSync('member', response.data.data.member);
							uni.setStorageSync('keycode', response.data.data.auth);
							this.$store.commit('setMember', response.data.data.member);
    						this.$store.commit('setMemberUid', response.data.data.member.id);
    						this.$store.commit('setKeycode', response.data.data.auth);
							//this.yidenglu = 1;
							this.denglu_xianshi = this.denglu_xianshi === 0 ? 1 : 0;
							this.$emit('login-success'); // 添加这行
							//关闭弹出
							//登录跳转到登录页面
							//uni.reLaunch({ url: "/pages/index/index" });
							//获取缓存里面的go_url
							var go_url = uni.getStorageSync('go_url');
							if(go_url){
								uni.reLaunch({ url: go_url });
							} else {
								uni.reLaunch({ url: "/pages/index/index" });
							}
						} else {
							uni.showToast({
								icon: 'none',
								title: response.data.msg
							});
						}
					})
				} catch (error) {
					console.error(error);
					uni.showToast({
						icon: 'none',
						title: '注册失败，请稍后重试'
					});
				}
			},
			// 登录认证码
			postRenzhengma(){
				var d = this;
				var phone = d.yonghu.phone; //手机号码可选
				
				// 判断 手机号不能为空
				// 添加手机号非空验证
				if(!phone) {
    			    uni.showToast({
    			        title: '请输入手机号码',
    			        icon: 'none'
    			    });
    			    return;
    			}
			
    			// 添加手机号格式验证
    			if(!/^1[3-9]\d{9}$/.test(phone)) {
    			    uni.showToast({
    			        title: '请输入正确的手机号码',
    			        icon: 'none'
    			    });
    			    return;
    			}
				this.vcodeTime = 60
				this.vcodeTimer = setInterval(() => {
					if (this.vcodeTime > 0) {
						this.vcodeTime--
					} else {
						clearInterval(this.vcodeTimer)
						this.vcodeTimer = null
					}
				}, 1000)
				uni.showToast({
					title: "获取验证码",
					icon: 'none'
				})
				var datas = '&id=' + phone;
				
				
				var post_data = getRequest(Api.postRenzhengma(phone),datas);
				var res;
				post_data.then(response => {
					res = response;
					if(res.data.code) {	
						uni.showToast({
							title: '发送成功',
							icon: 'success',
							duration: 2000
						});
					} else {
						uni.showToast({
							icon: 'none',
							title: response.data.msg
						});
					}
				})
			},
			// 手机用户注册
			async denglu_data(){
				try {
					var d = this;
					/*if(!d.xieyizhi || d.xieyizhi.length === 0) {
						
        			    uni.showToast({
        			        title: '请先同意用户协议和隐私协议',
        			        icon: 'none'
        			    });
        			    return;
        			}*/
					var username = d.yonghu.username; //账号
					var name = d.yonghu.name; //账号
					var password = d.yonghu.password; //密码
					var password2 = d.yonghu.password; //确认密码2
					var email = d.yonghu.email; //邮箱可选
					var phone = d.yonghu.phone; //手机号码可选
					var protocol = d.xieyizhi[0]; //是否同意协议
					//检查d.xieyizhi是否打勾

					var datas = "is_ajax=1&data[password]="+password+"&is_protocol="+protocol;
					if(username){
						datas += '&data[username]=' + username;
					}
					if(phone){
						datas += '&data[phone]=' + phone;
					}
					if(email){
						datas += '&data[email]=' + email;
					}
					if(name){
						datas += '&data[name]=' + name;
					}
					var post_data = postRequest(Api.postYonghuLogin(),datas);
					var res;
					post_data.then(response => {
						res = response;
						if(res.data.code) {	
							uni.showToast({
								title: '登录成功',
								icon: 'success',
								duration: 2000
							});
							 // 保存用户信息到本地storage
							//uni.setStorageSync('userInfo', response.data.data.member.auth);
							uni.setStorageSync('memberuid', response.data.data.member.uid);
							uni.setStorageSync('member', response.data.data.member);
							uni.setStorageSync('keycode', response.data.data.member.auth);
							this.$store.commit('setMember', response.data.data.member);
    						this.$store.commit('setMemberUid', response.data.data.member.uid);
    						this.$store.commit('setKeycode', response.data.data.auth);
							//头像
							this.touxiang = response.data.data.member.avatar;
							//昵称
							if(!response.data.data.member.name){
								this.name1 = response.data.data.member.username;

							} else {
								//昵称
								this.name1 = response.data.data.member.name;
							}
							
							//this.yidenglu = 1;
							this.denglu_xianshi = this.denglu_xianshi === 0 ? 1 : 0;
							this.$emit('login-success'); // 添加这行
							//关闭弹出
							//登录跳转到登录页面
							//获取缓存里面的go_url
							var go_url = uni.getStorageSync('go_url');
							if(go_url){
								uni.reLaunch({ url: go_url });
							} else {
								uni.reLaunch({ url: "/pages/index/index" });
							}
						} else {
							uni.showToast({
								icon: 'none',
								title: response.data.msg
							});
							this.tishi = response.data.msg;
							// 3秒后自动清空提示信息
							setTimeout(() => {
								this.tishi = '';
							}, 2000);
						}
					})
				} catch (error) {
					console.error(error);
					uni.showToast({
						icon: 'none',
						title: '注册失败，请稍后重试'
					});
				}
			},
			toPact(){
				console.log("协议");
			},
			pactChange(){
				this.pactChecked = !this.pactChecked;  // 切换勾选状态
				this.xieyizhi = this.pactChecked ? [1] : [];
			},
			exitlogin() {
				uni.removeStorageSync('userInfo');
				uni.removeStorageSync('memberuid');
				uni.removeStorageSync('keycode');
				uni.removeStorageSync('member');
				uni.reLaunch({ url: '/pages/login/login'})
			},
			// 返回首页
			shouye(){
				// 返回首页
				uni.reLaunch({ url: "/pages/index/index" });
			},
			//注册项目
			zhucexiangmu(){  
				var duixin = this;
				var postYonghuzhuceRequest = getRequest(Api.postYonghuRegiste());
				postYonghuzhuceRequest.then(response => {
					if (response.data.code == 1 && response.data.data && response.data.data.register) {
					    // 正确获取注册选项数据
						duixin.zhucexuanxiang = response.data.data.register.field || [];
						// 打印注册选项数据
						console.log('注册选项数据:', duixin.zhucexuanxiang);
						// 判断数组中是否包含'phone'元素						
						if (Array.isArray(duixin.zhucexuanxiang) && duixin.zhucexuanxiang.includes('email')) {
							duixin.loginType = 2;
							duixin.email = 1;
							console.log('未检测到phone字段，设置loginType为2');
						} else {
							duixin.loginType = 2;
							duixin.email = 0;
						}
			
						if (Array.isArray(duixin.zhucexuanxiang) && duixin.zhucexuanxiang.includes('username')) {
							duixin.loginType = 2;
							duixin.username = 1;
							console.log('未检测到phone字段，设置loginType为2');
						} else {
							duixin.loginType = 2;
							duixin.username = 0;
						}
						// 判断数组中是否包含'phone'元素	
						if(Array.isArray(duixin.zhucexuanxiang) && duixin.zhucexuanxiang.includes('phone')){
							duixin.loginType = 1;
							duixin.phone = 1;
							console.log('检测到包含phone字段，设置loginType为1');
						} else {
							duixin.loginType = 2;
						    duixin.phone = 0;
						}
						// 判断数组中是否包含'code'元素	
						if(response.data.data && response.data.data.register.code){
							duixin.code = 1;
							console.log('检测到需要验证码');
						} else {
							duixin.code = 0;
							console.log('不需要验证码');
						}
					} else {
						console.log('获取注册选项失败或数据格式不正确');
						duixin.zhucexuanxiang = [];
						duixin.loginType = 2;
					}
				}).catch(error => {
					console.error('获取注册选项请求失败:', error);
					duixin.zhucexuanxiang = [];
					duixin.loginType = 2;
				});
			},
			//新用户注册
			async zhuce_data(){
				try {
					var d = this;
					var username = d.yonghu.username; //账号
					var name = d.yonghu.name; //账号
					var password = d.yonghu.password; //密码
					var password2 = d.yonghu.password; //确认密码2
					var email = d.yonghu.email; //邮箱可选
					var phone = d.yonghu.phone; //手机号码可选
					var code = d.yonghu.code; //认证码
					var protocol = d.xieyizhi[0]; //是否同意协议
					// 验证密码不能为空
					if (!password) {
						uni.showToast({
							title: '请输入密码',
							icon: 'none'
						});
						return;
					}
					if(this.code==1 && !code){
						uni.showToast({
							title: '请输入验证码',
							icon: 'none'
						});
						return;
					}
					var datas = "is_ajax=1&data[password]="+password+"&is_protocol="+protocol+'&data[password2]='+password;
						if(username){
							datas += '&data[username]=' + username;
						}
						if(phone){
							datas += '&data[phone]=' + phone;
						}
						if(email){
							datas += '&data[email]=' + email;
						}
						if(name){
							datas += '&data[name]=' + name;
						}
						if(this.code==1){
							datas += '&data[code]=' + code;
						}
						var post_data = postRequest(Api.postYonghuRegiste(),datas);
						var res;
						post_data.then(response => {
							res = response;
							if(res.data.code) {	
								uni.showToast({
									title: '注册成功',
									icon: 'success',
									duration: 2000
								});
								 // 保存用户信息到本地storage
								//uni.setStorageSync('userInfo', response.data.data.member.auth);
								uni.setStorageSync('memberuid', response.data.data && response.data.data.member && response.data.data.member.uid);
								uni.setStorageSync('member', response.data.data && response.data.data.member && response.data.data.member);
								uni.setStorageSync('keycode', response.data.data && response.data.data.member && response.data.data.member.auth);
								this.$store.commit('setMember', response.data.data && response.data.data.member);
								this.$store.commit('setMemberUid', response.data.data && response.data.data.member && response.data.data.member.uid);
								this.$store.commit('setKeycode', response.data.data && response.data.data.member && response.data.data.member.auth);
								//头像
								this.touxiang = response.data.data.member.avatar;
								//昵称
								if(!response.data.data.member.name){
									this.name1 = response.data.data.member.username;
					
								} else {
									//昵称
									this.name1 = response.data.data.member.name;
								}
								
								//this.yidenglu = 1;
								this.denglu_xianshi = this.denglu_xianshi === 0 ? 1 : 0;
								this.$emit('login-success'); // 添加这行
								//关闭弹出
								//登录跳转到登录页面
								//获取缓存里面的go_url
								var go_url = uni.getStorageSync('go_url');
								if(go_url){
									uni.reLaunch({ url: go_url });
								} else {
									uni.reLaunch({ url: "/pages/index/index" });
								}
							} else {
								uni.showToast({
									icon: 'none',
									title: response.data.msg
								});
							}
						})
					} catch (error) {
						console.error(error);
						uni.showToast({
							icon: 'none',
							title: '注册失败，请稍后重试'
						});
					}
				
			},
			//获取注册认证码
			getRenzhengma(){
				console.log('获取注册认证码');
				// 添加时间戳防止缓存
				const timestamp = new Date().getTime();
				this.get_rzm = Api.getZhuceRenzhengma() + '?t=' + timestamp;
				console.log('更新后的认证码URL:', this.get_rzm);
			}





		}
	}
</script>

<style scoped lang="scss">
/*引入css main.css*/

	.content {
		
		
		display: flex;
		flex-direction: column;
		/*align-items: center;*/
		
		background-color: #f3f3f3;
		
		margin-bottom: 0px;
		
		/*height: 100vh;*//* 添加全屏 */
		/*width: 100vw;*/ /* 添加全屏*/
		box-sizing: border-box;
		overflow-x: hidden;

		
		

	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	/* 屏幕宽度大于786px时隐藏uni-page-head */
    @media (min-width: 786px) {
        uni-page-head {
            display: none !important;
            opacity: 0 !important;
            height: 0 !important;
            visibility: hidden !important;
        }
    }
	/*.d-daohang{
		
		width: 600rpx;
	}*/
	/* 添加在style部分 */
	.d-daohang-zuo {
    position: fixed;
    left: 0;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #f5f5f5;
    z-index: 100;
	box-shadow: 2px 0 5px rgba(177, 177, 177, 0.1);
  }
  
  .d-daohang-you {
    position: fixed;
    left: 180rpx;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #fff;
    z-index: 100;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }
   
   
   
   
   
   
   
   
   
 
   
  .d-erji-item {
    height: 60rpx;
    line-height: 60rpx;
    padding: 0 20rpx;
   /* border-bottom: 1px solid #f0f0f0;*/
  }
  
  .d-erji-item:active {
    background: #f5f5f5;
  }
  .you-guding {
	position: fixed;
	top: 0; /* 根据头部高度调整 */
	/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
	transition: all 0.3s ease;
}
/* 大于786px时的样式 */
@media screen and (min-width: 1024px) {
	.d-bianhua-10 {
		padding: 30px;
	}
	.pc-zuo-520 {
		margin-left: 520rpx;
	}
	.you-guding {
		position: fixed;
			
		top: 60px; /* 根据头部高度调整 */
		/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
		transition: all 0.3s ease;
	}
		
	
}
	.denglu {
		width: 100%;
		/* 最大宽度 */
		
	    height: 100%;
	    z-index: 100000;
		left: 0;
	  top: 0;
	  position: fixed;
	  /*background-color: rgba(0, 0, 0, 0.5);*/ /* 半透明黑色背景 */
	  
	}
	
	.denglu_2 {
	  width: 100%;
	  /*最大宽度*/
	  max-width: 800rpx;
	  height: 900rpx;
	  position: fixed;
	  left: 50%;
	  top: 50%;
	  transform: translate(-50%, -50%);
	  background-color: rgba(255, 255, 255, 1); /* 半透明黑色背景 */
	  border-radius: 20rpx; /* 可选：添加圆角 */
	}
	.huise {
		background-color: #f5f5f5;
		height: 900rpx;
		border-radius: 0rpx 20rpx 20rpx 0 ; /* 可选：添加圆角 */
	}
	.d-erweima {
		width: 380rpx;
		height: 380rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		/* 左右居中 */
		margin-left: auto;
		margin-right: auto;
		/* 上下居中 */
		margin-top: auto;
		margin-bottom: auto;
		/* 居中 */
	}
	.title {
		padding-top: 30rpx;
		padding-bottom: 50rpx;
		view {
			padding-left: 64rpx;
			font-size: 48rpx;
			font-weight: 700;
			color: #383838;
		}
	}
	.form {
			flex: 1;
			padding: 0 64rpx;
	
			.tab {
				display: flex;
				align-items: center;
				justify-content: space-between;
				/*background-color: #ecf1fb;*/
				height: 100rpx;
				/*background: linear-gradient(180deg, #e3ebf9 0%, #ffffff 100%);*/
	
				view {
					width: 340rpx;
					line-height: 100rpx;
					text-align: center;
					color: #9e9e9e;
					position: relative;
				}
	
				view::after {
					content: '';
					width: 50rpx;
					height: 8rpx;
					display: block;
					background-color: #16afa8;
					border-radius: 4rpx;
					position: absolute;
					left: 50%;
					bottom: 14rpx;
					transform: translateX(-50%);
					opacity: 0;
				}
	
				view.select {
					background-color: #fff;
					color: #06adb3;
				}
	
				view.type1.select {
					border-radius: 0 40rpx 0 0;
				}
	
				view.type2.select {
					border-radius: 40rpx 0 0;
				}
	
				view.select::after {
					opacity: 1;
				}
			}
	
			.inputs {
				margin-bottom: 80rpx;
	
				>view {
					height: 96rpx;
					border-bottom: 1rpx solid #cdcdcd;
					display: flex;
					align-items: center;
	
					input {
						flex: 1;
					}
				}
	
				.account {
					margin-bottom: 48rpx;
	
					view {
						padding-right: 20rpx;
						margin-right: 20rpx;
						border-right: 1rpx solid #cdcdcd;
					}
				}
	
				.vcode {
					text {
						text-wrap: nowrap;
					}
				}
			}
	
			.button {
				view {
					line-height: 96rpx;
					border-radius: 20rpx;
					text-align: center;
					font-size: 32rpx;
					color: #ffffff;
					background-color: #16afa8;
				}
			}
	
			.tip {
				font-size: 28rpx;
				text-align: center;
				margin-top: 30rpx;
				color: #808080;
			}
		}
		.pact {
			display: flex;
			align-items: center;
			justify-content: center;
			padding-bottom: 70rpx;
			font-size: 24rpx;
	
			text {
				color: #3ba662;
			}
	
			radio {
				:deep(.uni-radio-input) {
					border: 1rpx solid #3ba662;
				}
	
				transform:scale(0.6)
			}
		}
		.d-xiala-0 {
		  position: relative;
		  display: inline-block;
		  
		  &:hover {
			  .d-xiala-1 {
			    display: block;
			  }
			}
		}
		.d-xiala-1 {
			/*margin: 30rpx;*/
		  position: absolute;
		  top: 100%;
		  left: 0;
		  background-color: #fff;
		  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
		  border-radius: 8rpx;
		  padding: 5rpx 16rpx;
		  z-index: 1000;
		  min-width: 200rpx;
	      /*display: block;*/ /* 修改为block */
		  white-space: nowrap;
	
		 /* &.show {
		    display: block;
		  }*/
		}
		.d-denglu {
		  position: relative;
		}
		/* #ifdef APP || H5 */
		.d-kuan-baifen-70-cm {
			width: 100%;
		}
		/* #endif */
		/* #ifdef MP */
		.d-kuan-baifen-70-cm {
			width: 70%;
		}
		/* #endif */
</style>
